package com.weipai.education.dao.impl;

import com.weipai.education.dao.CustomerDao;
import com.weipai.education.mapper.CusRecordMapper;
import com.weipai.education.mapper.CusTakeGoodsMapper;
import com.weipai.education.mapper.CustomerMapper;
import com.weipai.education.model.CusRecord;
import com.weipai.education.model.CusTakeGoods;
import com.weipai.education.model.Customer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @Author: 曹朋飞
 * @Date: 2018/12/10 17:21
 */
@Repository
public class CustomerDaoImpl implements CustomerDao{

    @Autowired
    private CustomerMapper customerMapper;
    @Autowired
    private CusRecordMapper cusRecordMapper;
    @Autowired
    private CusTakeGoodsMapper cusTakeGoodsMapper;

    @Override
    public int update(Customer customer) {
        return customerMapper.updateByPrimaryKeySelective(customer);
    }

    @Override
    public int insert(Customer customer) {
        return customerMapper.insert(customer);
    }

    @Override
    public Customer selectByPrimaryKey(String id) {
        return customerMapper.selectByPrimaryKey(Integer.parseInt(id));
    }

    @Override
    public List<Map<String, Object>> list(Integer start, Integer size, String key, String userId) {
        return customerMapper.list(start, size, key, userId);
    }

    @Override
    public Integer listAmount(String key, String userId) {
        return customerMapper.listAmount(key, userId);
    }

    @Override
    public int saveCusRecord(CusRecord cusRecord) {
        return cusRecordMapper.insert(cusRecord);
    }

    @Override
    public Map<String, Object> getCustomerInfo(String customerId) {
        return customerMapper.getCustomerInfo(customerId);
    }

    @Override
    public List<Map<String, Object>> getCusRecord(String customerId) {
        return cusRecordMapper.getCusRecord(customerId);
    }

    @Override
    public void insertCusTakeGoods(CusTakeGoods cusTakeGoods) {
        cusTakeGoodsMapper.insert(cusTakeGoods);
    }

    @Override
    public List<Map<String, Object>> getCusTakeGoods(String customerId) {
        return cusTakeGoodsMapper.getCusTakeGoods(customerId);
    }
}
